<template>
	<div>
		<el-dialog title="身份认证" :visible.sync="dialogVisible" width="30%" :before-close="reset">
			<el-input class="mb" v-model="userNum" placeholder="请输入账号" clearable></el-input>
			<el-input v-model="pw" type="password" placeholder="请输入密码" clearable></el-input>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="login">确 定</el-button>
	   			<el-button @click="reset">重置</el-button>
  			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		data(){
			return {
				 dialogVisible: true,
				 userNum:'',
				 pw:''
			}
		},
		methods:{
			reset(){
				this.userNum='';
				this.pw='';
			},
			login(){
				let that = this;
				let ajaxData = {
					num:that.userNum,
					pw:that.pw
				};
				that.axios.post('http://blog.cn/user/login', ajaxData)
					.then(response => {
						if(response.data.status){
							this.$router.push('Index');
						}
					})
					.catch(error => {
						console.log(error);
						alert('网络错误，不能访问');
					});
			}
		}
	}
</script>

<style scoped="scoped">
 .mb {
 	margin-bottom: 20px;
 }
</style>